libs/guest: Fix leak on realloc failure in backup_ptes()
authorEdwin Török <edwin.torok@cloud.com>
Fri, 3 Mar 2023 07:03:19 +0000 (08:03 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 3 Mar 2023 07:03:19 +0000 (08:03 +0100)
commitfa8250f1920413f02b63551a6a4d8ef0b47891a8
treee1db03536068241ad006a462b63266164f9634f7
parent01f85d835bb10d18bdab2cc780ea5ad47004516d
libs/guest: Fix leak on realloc failure in backup_ptes()

From `man 2 realloc`:

  If realloc() fails, the original block is left untouched; it is not freed or moved.

Found using GCC -fanalyzer:

  |  184 |         backup->entries = realloc(backup->entries,
  |      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  |      |         |               | |
  |      |         |               | (91) when ‘realloc’ fails
  |      |         |               (92) ‘old_ptes.entries’ leaks here; was allocated at (44)
  |      |         (90) ...to here

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
master commit: 275d13184cfa52ebe4336ed66526ce93716adbe0
master date: 2023-02-27 15:51:23 +0000
tools/libs/guest/xg_offline_page.c